import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    redirect: '/login',  //重定向路径
  },
  {
    path: '/',
    name: 'loyout',
    component: () => import("../views/loyout"),
    children: [{
      path: 'login',
      name: 'login',
      component: () => import("../views/login.vue"),
      meta: { title: "杨杨交易系统-登录" }
    },

    {
      path: "persionRegister",
      name: 'persionRegister',
      component: () => import("../views/register/persionRegister"),
      meta: { title: "杨杨交易系统-个人注册" }
    },

    {
      path: "enterpriseRegister",
      name: 'enterpriseRegister',
      component: () => import("../views/register/enterpriseRegister"),
      meta: { title: "杨杨交易系统-企业注册" }
    },
    {
      path: "resetPw",
      name: "resetPw",
      component: () => import("../views/resetPassword.vue"),
      meta: { title: "杨杨交易系统-重置密码" }
    },

    ]
  },

  {
    path: "/main",
    name: "main",
    component: () => import("../views/homepage/index.vue"),
    meta: { title: "杨杨交易系统-首页" },
    redirect: '/main/takeout/category',
    children: [
      {
        path: "takeout",
        name: "takeout",
        component: () => import("../views/takeOut/index.vue"),
        meta: { title: "杨杨交易系统-外卖" },
        children: [
          {
            path: "category",
            name: "category",
            component: () => import("../views/takeOut/catgoryDish.vue"),
            meta: { title: "杨杨交易系统-菜品" }
          },
          {
            path: "setMeal",
            name: "setMeal",
            component: () => import("../views/takeOut/categorySetmeal.vue"),
            meta: { title: "杨杨交易系统-套餐" }
          }
        ]
      }, {
        path: "shoppingCart",
        name: "shoppingCart",
        component: () => import("../views/shoppingCart/shoppingCart.vue"),
        meta: { title: "杨杨交易系统-购物车" }
      },
      {
        path: "order",
        name: "order",
        component: () => import("../views/order/orders/orderTable.vue"),
        meta: {
          title: "订单管理-订单详情",
          showFather: true,
        },
        children: [
          {
            path: "orderDetail",
            name: "orderDetail",
            component: () => import("../views/order/orders/orderDetail.vue"),
            meta: {
              title: "订单管理-订单详情",
              showFather: false,
            },
          }
        ]
      },
      {
        path: "orderCount",
        name: "orderCount",
        component: () => import("../views/order/orderCount.vue"),
        meta: { title: "订单管理-订单统计" }
      },
      {
        path: "orderFk",
        name: "orderFk",
        component: () => import("../views/order/orderFk.vue"),
        meta: { title: "订单管理-订单反馈" }
      }

      ,

      {
        path: "personalCenter",
        name: "personalCenter",
        // component: () => import("../views/personalCenter/personalCenter.vue"),
        redirect: "personalCenter",
        meta: { title: "杨杨交易系统-个人中心" },
        children: [
          {
            path: "",
            name: "personalCenter",
            component: () => import("../views/personalCenter/personalCenter.vue"),
            meta: { title: "杨杨交易系统-个人中心" }
          },
          {
            path: "address",
            name: "address",
            component: () => import("../views/personalCenter/address.vue"),
            meta: { title: "杨杨交易系统-收货地址" }
          }
        ]
      },
      {
        path: "account",
        name: "account",
        meta: { title: "杨杨交易系统-账户管理" },
        component: () => import("../views/account/account.vue")
      }
    ],

  },
  {
    path: '/test',
    name: "test",
    component: () => import("@/views/test/test.vue"),
    meta: { title: '测试界面' },
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router
